1. Technical Field
The present invention relates in general to a method and system for data processing and in particular to a method and system for processing data input to a data processing system utilizing an input device having a number of keys. Still more particularly, the present invention relates to a method and system for translating keyboard scan codes into function and character codes which may be utilized by a number of data processing systems having diverse operating systems and input devices.
2. Description of the Related Art
Although a number of input devices such as mice, touch screens, and digitizing tablets have been recently developed to enhance user interface to data processing systems, the keyboard remains the primary device utilized to input data to data processing systems. A typical keyboard includes a number of keys, which are each associated with at least one character or function. For example, the enhanced keyboard commonly utilized with personal computers such as the IBM Personal System 2 (PS/2) has 101 keys, including alphanumeric character keys, key modifiers (Alt, Shift, Ctrl, etc.), cursor positioning keys, and 12 function keys (F1-F12).
In a typical personal computer system, keystrokes are detected by a microcontroller within the keyboard which continuously scans each of the keys to determine if a key has been pressed or released. When a change in the state of a key is detected, the microcontroller generates a unique scan code which specifies the key that has changed state and whether the key has been pressed (a make code) or released (a break code). The microcontroller within the keyboard then serially transmits the scan code generated by the keystroke, which is typically one or two bytes in length, to a keyboard driver within the system unit. The keyboard driver, in turn, issues an interrupt to the central microprocessor (CPU) indicating that a scan code is available to be read.
After the scan code generated by the keyboard microcontroller is read by the CPU, the CPU translates the scan code into an input code recognizable by the personal computer operating system utilizing a translation table within the Basic Input/Output System (BIOS) code stored in ROM. The translation table is arranged as a fixed length array in which a number of scan codes are stored in association with corresponding input codes. As will be understood by those skilled in the art, the translation table must supply a scan code translation for each combination of keyboard type and country layout (i.e., national language) supported by the personal computer system. Because a number of keyboard behaviors are unique to a specific country layout, the translation table typically includes hardcoded operating system-dependent commands in order to reduce the memory required to store the translation table. For example, translation tables may include operating system-dependent commands to translate scan codes input in conjunction with particular key modifiers (e.g., "a" with Caps Lock and Shift) for a particular country layout. After the CPU has translated the input scan code into an input code by referencing the translation table, the input code is processed in accordance with the operating system software executing within the CPU.
Although the conventional method of converting keyboard keystrokes into character and function input codes performs efficiently for a given combination of keyboard hardware, country layout, and operating system, a problem arises when the growing number of keyboard configuration and operating systems is considered. Since the translation table which converts scan codes into character and function input codes contains operating system-dependent special purpose code written specifically for each combination of country layout and keyboard hardware, the translation table is not transportable between data processing systems utilizing different operating systems and keyboard hardware. Thus, a translation table must be written for each permutation of operating system, country layout, and keyboard hardware.
Consequently, it would be desirable to provide a method and system for translating keyboard scan codes into function and character input codes, where the method and system may be utilized by data processing systems having diverse operating systems and keyboard hardware.